<?php

namespace app\plugins\clerk\controllers\api;


use app\core\response\ApiCode;
use app\models\ClerkUser;

class ApiController extends \app\controllers\api\ApiController
{

    public function beforeAction($action)
    {
        //权限判断
        $permission = \Yii::$app->branch->childPermission(\Yii::$app->mall->user->adminInfo);
        if (empty(\Yii::$app->plugin->getInstalledPlugin('clerk'))||!in_array('clerk', $permission)||empty(ClerkUser::findOne(['user_id' => \Yii::$app->user->id, 'mall_id' => \Yii::$app->mall->id, 'is_delete' => 0]))) {
            \Yii::$app->response->data = ['code' => ApiCode::CODE_ERROR, 'msg' => '无核销信息权限'];
            return false;
        }
        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }
}
